<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../../vue.js"></script>
    <title>Document</title>
</head>
<style>
    * {
        margin-top: 20px;
    }

    .root {
        height: 50px;
        background-color: tomato;
    }

    .box1 {
        padding: 5px;
        background-color: aqua;
    }

    .box2 {
        padding: 5px;
        background-color: orange;
    }
    .list {
        width: 200px;
        height: 200px;
        background-color: tomato;
        overflow:auto;
    }
    .list li {
        width: 100px;
        height: 100px;
        background-color: yellow;
    }
</style>

<body>
    <div class="app">
        <h1>欢迎来到我的{{world}}}</h1>
        <!-- 1.prevent:阻止默认事件  -->
        <a href="http://www.baidu.com" @click.prevent="showInfo">点击提示信息</a>

        <!-- 2.stop:阻止事件冒泡 (常用); -->
        <div class="root" @click="showInfo">
            <button @click.stop="showInfo">点击提示信息</button>
        </div>

        <!-- 3.once:事件只触发一次 (常用); -->
        <button @click.once="showInfo">点击提示信息</button>

        <!--  4.capture:使用事件的捕获模式 -->
        <div class="box1" @click.capture="show">
            div1
            <div class="box2" @click="show">
                div2
            </div>
        </div>

        <!--  5.self:只有event.target是当前操作的元素是才触发事件 -->
        <div class="root" @click.self="showInfo">
            <button @click="showInfo">点击提示信息</button>
        </div>

        <!--  6.passive:事件的默认行为立即执行,无需等待回调函数执行完毕 -->
        <ul @wheel="demo" class="list"> <!-- @scroll 鼠标滑轮and键盘上下  @wheel 鼠标滑轮的问题 -->
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
        </ul>
    </div>
</body>
<script>
    new Vue({
        data: {
            world: '世界'
        },
        methods: {
            showInfo(e) {
                alert('进入世界')
            },
            show(e) {
                alert('捕获')
            },
            demo() {
                console.log(111)
            }
        }
    }).$mount('.app')
</script>

</html>